package phase1.part3;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * 
 * @author John Girata
 * @version Nov 8, 2012
 */
public class State {
	private String label;
	private boolean accepting;
	private String tokenClass;
	private List<Transition> transitions;
	
	public State(String label) {
		this.label = label;
		
		accepting = false;
		tokenClass = "";
		transitions = new ArrayList<>();
	}

	public boolean isAccepting() {
		return accepting;
	}

	public void setAccepting(boolean accepting) {
		this.accepting = accepting;
	}

	public String getTokenClass() {
		return tokenClass;
	}

	public void setTokenClass(String tokenClass) {
		this.tokenClass = tokenClass;
	}

	public String getLabel() {
		return label;
	}
	
	public void addTransition(Transition transition) {
		transitions.add(transition);
	}
	
	public List<Transition> getTransitions() {
		return transitions;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((label == null) ? 0 : label.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof State))
			return false;
		State other = (State) obj;
		if (label == null) {
			if (other.label != null)
				return false;
		} else if (!label.equals(other.label))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "State [label=" + label + ", accepting=" + accepting
				+ ", tokenClass=" + tokenClass + "]";
	}
}
